/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cplex;

import ilog.concert.*;
import ilog.cplex.IloCplex;

/**
 *
 * @author stkr
 */
public class Test{
    
    public static void main(String[] args){
        try{
            
            
            
            
            IloCplex configurationGen = new IloCplex(); // Loeser fuer das Pricing Problem (Column Generation)
            
            double[] itemSizes = {1.0/2, 1.0/3, 1.0/4};  // Itemgroessen
            double[] pis        = {1, 0.375, 0.25};
            int[] lb = {0,0,0};
            int[] ub = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
            
            IloIntVar[] varGen = configurationGen.intVarArray(3, lb, ub); // Variablen des Pricing Problems
            IloObjective profit = configurationGen.addMaximize(configurationGen.scalProd(varGen,pis));
                    //IloNumExpr eexpr = configurationGen.sum(configurationGen.prod(varGen[0],pis[0]),
                                     // configurationGen.sum(configurationGen.prod(varGen[1],pis[1]), configurationGen.prod(varGen[2],pis[2])));
                    IloLinearNumExpr expr = configurationGen.linearNumExpr();
                    expr.addTerm(itemSizes[0],varGen[0]);
                    expr.addTerm(itemSizes[1],varGen[1]);
                    expr.addTerm(itemSizes[2],varGen[2]);
                    //IloLinearNumExpr expr2 = configurationGen.linearNumExpr();
                    //expr2.addTerm(pis[0],varGen[0]);
                    //expr2.addTerm(pis[1],varGen[1]);
                    //expr2.addTerm(pis[2],varGen[2]);
                   
                            //configurationGen.sum(configurationGen.prod(varGen[0],itemSizes[0]),
                            //configurationGen.prod(varGen[1],itemSizes[1]), configurationGen.prod(varGen[2],itemSizes[2]));
                    IloRange xzy = configurationGen.addLe(expr, 1);
                    //IloObjective obj = configurationGen.maximize(expr2);
                    //configurationGen.add(obj);
                            //addRange(0, expr, 0);
                            //addRange(0, configurationGen.scalProd(varGen, itemSizes), 1, "c1");
                  //  configurationGen//addMaximize(eexpr);
                    //        .addMaximize(configurationGen.scalProd(varGen,pis));
            
                    

                    
                    double[] pi = {1,0,0};//cplex.getDuals(rng);

                    
                    
                    //configurationGen.setLinearCoefs(profit, pi, varGen);
                    configurationGen.solve();
                    System.out.println(configurationGen.getObjValue());
                    double[] x  = configurationGen.getValues(varGen);
                    

                    for (int j = 0; j < x.length; j++){
                        configurationGen.output().println("Value of Variable " + j + " = " + x[j]);
                    }
                
            
            
            configurationGen.end();
        }
        catch (IloException e) {
         System.err.println("Concert exception '" + e + "' caught");
    }
        
    }
    
    
      
        
       
        
        

}